// 写验证规则
const joi = require('joi')
    // 用户名的验证规则
const username = joi.string().alphanum().min(3).max(10).required()
    // 密码的验证规则
const password = joi.string().pattern(/^[\S]{6,12}$/).required()
    // 登录表单的验证规则对象
const email = joi.string().email({ minDomainSegments: 2, tlds: { allow: ['com', 'net'] } })
const mobile = joi.string().pattern(/^1[3-9]\d{9}$/)
exports.login_schema = {
    // 表示需要对req.body 中的数据进行验证
    body: {
        username,
        password,
        email,
        mobile
    }
}

exports.user_create_schema = {
    body: {
        username,
        password,
        email,
        mobile
    }
}

exports.user_update_schema = {
    body: {
        email,
        mobile
    }
}